// Include files.
#include "WPILib.h"
#include "LiveWindowService.hpp"

/**
 *  Constructor for LiveWindowService.
 */
LiveWindowService::LiveWindowService() :
	m_liveWindow(*LiveWindow::GetInstance())
{
	/* The following code in this block is derived from 
	 * WPILib, which is licenced under the licence specified
	 * in "Licence-WPILib.txt".
	 */
	
	NetworkTable::GetTable("LiveWindow")->GetSubTable("~STATUS~")->PutBoolean("LW Enabled", false);
}

/**
 *  Destructor for LiveWindowService.
 */
LiveWindowService::~LiveWindowService()
{
}

/**
 *  Handle service start by enabling LiveWindow.
 */
void LiveWindowService::HandleStart()
{
	m_liveWindow.SetEnabled(true);
}

/**
 *  Handle service start by disabling LiveWindow.
 */
void LiveWindowService::HandleStop()
{
	m_liveWindow.SetEnabled(false);
}

/**
 *  Handle service periodic loop by running LiveWindow.
 */
void LiveWindowService::HandlePeriodic()
{
	m_liveWindow.Run();
}

/**
 *  Get a reference to the managed LiveWindow object.
 *  
 *  @return A reference to the managed LiveWindow object.
 */
LiveWindow &LiveWindowService::GetLiveWindow()
{
	return m_liveWindow;
}
